import sqlite3
from typing import List, Dict, Optional, Any
class SQLUtil:
    def __init__(self,db_path:str="text.sqlite"):
        self.db_path=db_path
        self.conn = sqlite3.connect(db_path)
        self.cur = self.conn.cursor()
    def createTable(self,table_name:str,columns):
        cols=','.join(f"{name}{dtype}"for name,dtype in columns)
        sql=f'''create table if not exists {table_name} ({cols})'''
        self.cur.execute(sql)
        self.conn.commit()

    def insert(self,table_name:str,data:Dict[str,str]):
        columns=','.join(list(data.keys()))
        placeHolder=','.join(['?']*len(data))
        sql="insert into {table_name} ({columns}) values ({placeHolder})"
        self.cur.execute(sql,tuple(data.values()))
        self.conn.commit()

